package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@SpringBootApplication
@Controller
@RequestMapping
public class Demo1Application {
    
    @Autowired
    StudentMapper studentMapper;

    public static void main(String[] args) {
        SpringApplication.run(Demo1Application.class, args);
    }


    @RequestMapping
    @ResponseBody
    public String index(){
        return "index";
    }


    @RequestMapping("index")
    public String index2(ModelMap map){

        Student student = new Student();
        student.setName("张三"+Math.random());
        student.setAge(99);
        studentMapper.save(student);
        map.put("hello", "你好");
        map.put("java", "这是一个Java项目");
        List<Student> list = studentMapper.list();
        map.put("list", list);
        return "index";
    }

}
